package com.caiyouxi.app.service.impl;

import com.caiyouxi.app.mapper.AppCategoryBeanMapper;
import com.caiyouxi.app.model.AppCategoryBean;
import com.caiyouxi.app.service.AppCategoryBeanService;
import com.caiyouxi.common.bean.QueryParams;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.cache.RedisService;
import com.caiyouxi.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AppCategoryBeanServiceImpl extends BaseService implements AppCategoryBeanService {
    @Autowired
    private AppCategoryBeanMapper mapper;
    @Autowired
    private RedisService redisService;

    @Override
    public ResData delete_app_category(AppCategoryBean bean) {
        return success(mapper.delete_app_category(bean.getId()));
    }

    @Override
    public ResData insert_app_category(AppCategoryBean bean) {
        return success(mapper.insert_app_category(bean));
    }

    @Override
    public ResData select_app_category(AppCategoryBean bean) {
        return success(mapper.select_app_category(bean.getId()));
    }

    @Override
    public ResData update_app_category(AppCategoryBean bean) {
        return success(mapper.update_app_category(bean));
    }

    @Override
    public ResData get__app_category_list(AppCategoryBean bean) {
        Integer page_list = Integer.parseInt(redisService.get("sys.pagesize").toString());
        QueryParams pageList = new QueryParams();
        if(bean.getPage_size() == 0){
            bean.setPage_size(page_list);
        }
        pageList.setPage_size(bean.getPage_size());
        pageList.setPage(bean.getPage());
        pageList.setList(mapper.get_app_category_list(bean));
        pageList.setTotal(mapper.get_app_category_count(bean));
        return success(pageList);
    }
}
